package com.btpj.module_login.data.remote

import com.btpj.jetpack.entity.User
import com.btpj.jetpack.http.RetrofitClient
import com.btpj.jetpack.http.api.BaseRepository
import com.btpj.jetpack.entity.ApiResult

class LoginRepository(private val retrofitClient: RetrofitClient) : BaseRepository() {

    suspend fun login(username: String, password: String): ApiResult<User> {
        return callRequest {
            handleResponse(
                retrofitClient.create(LoginApi::class.java).login(username, password)
            )
        }
    }

    suspend fun register(
        username: String,
        password: String,
        surePassword: String
    ): ApiResult<User> {
        return callRequest {
            handleResponse(
                retrofitClient.create(LoginApi::class.java)
                    .register(username, password, surePassword)
            )
        }
    }
}